<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            text-align: center;
            font-size: 50px
        }
    </style>
    <script src="../../vue.js"></script>
</head>

<body>
    <div class="box">


        <wzp></wzp>

    </div>
    <script>
        var componentA = {
            data: function() {
                return {
                    style: ['飘逸', '帅气', '上进', '幽默', '阳光'],
                    index: 1,
                    name: '飘逸',
                    colorArr: ['skyblue', 'purple', 'red', 'orange', 'pink'],
                    iscolor: 'skyblue'
                }
            },
            template: `
            <div>
                <p :style='{color:iscolor}'> wzp： {{ name }}</p>  <br />
                <button @click='handle'>还有呢</button>  
            </div>
            `,
            methods: {
                handle() {
                    if (this.index > 4) {
                        this.index = 0
                    }
                    this.iscolor = this.colorArr[this.index]
                    this.name = this.style[this.index]
                    this.index++
                }
            }
        }

        var vm = new Vue({
            el: '.box',
            data: {},
            components: {
                'wzp': componentA
            }
        })
    </script>
</body>

</html>